import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import postcssPxToViewport from 'postcss-px-to-viewport';
import tailwindcss from '@tailwindcss/vite';
import path from 'path'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react(),tailwindcss()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      '~@': path.resolve(__dirname, './src/assets/styles')
    }
  },
  css: {
    preprocessorOptions: {
      less: {
        additionalData: `@import "src/assets/styles/common.less";@import "src/assets/styles/antdCover.less";`, // 全局注入
        javascriptEnabled: true
      }
    },
    postcss: {
      plugins: [
        postcssPxToViewport({
          unitToConvert: 'px',
          viewportWidth: 375,
          unitPrecision: 5,
          propList: ['*'],
          viewportUnit: 'vw',
          fontViewportUnit: 'vw',
          selectorBlackList: [],
          minPixelValue: 1,
          mediaQuery: false,
          replace: true,
          exclude: [],
          include: undefined,
          landscape: false,
          landscapeUnit: 'vw',
          landscapeWidth: 1334
        })
      ]
    }
  }
})
